Linux anti-select Delete file
The easiest way is to # shopt-s Extglob (open Extglob mode)# RM-FR! (File1)If you want to exclude multiple, you can do this:# RM-RF! (File1|file2) LINUXRM Delete Other file method totals outside the specified fileFirst,
A colleague of mine once asked me a question: how do I delete all files in the directory except for some files under Linux? At the time, I told him that it could be solved by pattern matching method. But in fact, in addition, there are other methods,
In Linux, the RM + grep command deletes all files except the specified file. Previous/next article 10:17:38/personal classification: liunx (185)/comment (0)/score (0/0) this afternoon, I was asked how to delete all the files in a directory except
deleting files and directories in PHP is actually very simple as long as two functions one is unlink a rmdir function, if you want to implement delete directories and directories under the file we need to use the recursive operation.
Function code:
Function code: Deletes only the files in the specified directory, and does not delete the directory folder.
The code is as follows
Copy Code
Class Shanchu {All files under the looping directoryfunction Delfileunderdir
First, batch and shell
Directories and documents:
Copy Code code as follows:
C:\TESTFOLDER\TEST
├─test2
└─test3
Test.txt
Delete the directory and all the files under it:
Copy Code code as follows:
Delete files other than specified files in linux 1. common commands for deleting files and folders in Linux: delete files: rmfilewww.2cto.com delete folders: rm-rfdir, rmdir can only delete empty folders. II. delete the specified file...
Delete
Recently, when processing planning resource files, you need to synchronize all the files in directory A to the files in directory B and delete all the unnecessary files in directory B. Therefore, you can use the -- delete parameter of rsync to
Delete Files other than specified files in linux 1. Common commands for deleting files and folders in Linux: delete files: rm file www.2cto.com delete folders: rm-rf dir, rmdir can only delete empty folders. Ii. Delete all files other than the
I am a new Linux user. Now I need to clean up a download directory of files, in fact, I just want to delete from the ~/download/folder except for files in the following format, other files:
1.*.iso-all ISO format files.2.*.zip-Files in all zip
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.